package com.ttc.group2.videochat.database;

import android.database.sqlite.SQLiteDatabase;
import android.provider.BaseColumns;

public class Tables {

	public static class UserTable implements BaseColumns {
		public static final String TableName = "UserTb";
		public static final String USER_ID = "user_id";
		public static final String FULL_NAME = "full_name";
		public static final String EMAIL = "email";
		public static final String PHONE = "phone";
		public static final String CUSTOM_DATA = "custom_data";
		public static final String AVATAR_URL = "avatar_url";
		public static final String STATUS = "status";
		public static final String IS_ONLINE = "is_online";
		public static final String[] COLUMNS = { USER_ID, FULL_NAME, EMAIL,
				PHONE, CUSTOM_DATA, AVATAR_URL, STATUS, IS_ONLINE };

		public static void setup(SQLiteDatabase db) {
			db.execSQL(String
					.format("CREATE TABLE IF NOT EXISTS %s "
							+ "(%s INTEGER PRIMARY KEY AUTOINCREMENT, %s INTEGER, %s TEXT NOT NULL, %s TEXT NOT NULL, "
							+ "%s TEXT, %s TEXT, %s TEXT, %s TEXT, %s INTEGER)",
							TableName, _ID, USER_ID, FULL_NAME, EMAIL, PHONE,
							CUSTOM_DATA, AVATAR_URL, STATUS, IS_ONLINE));
		}
	}

	public static class FriendTable implements BaseColumns {
		public static final String TableName = "FriendTb";
		public static final String OwnerId = "_ownerId";
		public static final String FriendId = "_friendId";
		public static final String[] COLUMNS = { OwnerId, FriendId };

		public static void setup(SQLiteDatabase db) {
			db.execSQL(String
					.format("CREATE TABLE IF NOT EXISTS %s "
							+ "(%s INTEGER PRIMARY KEY AUTOINCREMENT, %s INTEGER, %s INTEGER)",
							TableName, _ID, OwnerId, FriendId));
		}
	}

	public static class MessageTable implements BaseColumns {
		public static final String TableName = "MessageTb";
		public static final String MESSAGE_ID = "message_id";
		public static final String GROUP_ID = "dialog_id";
		public static final String SENDER_ID = "sender_id";
		public static final String RECIPIENT_ID = "recipient_id";
		public static final String BODY = "body";
		public static final String TIME = "time";
		public static final String[] COLUMNS = { MESSAGE_ID, GROUP_ID,
				SENDER_ID, RECIPIENT_ID, BODY, TIME };

		public static void setup(SQLiteDatabase db) {
			db.execSQL(String
					.format("CREATE TABLE IF NOT EXISTS %s "
							+ "(%s INTEGER PRIMARY KEY AUTOINCREMENT, %s INTEGER, %s INTEGER, %s INTEGER, %s INTEGER, %s TEXT, %s TEXT)",
							TableName, _ID, MESSAGE_ID, GROUP_ID, SENDER_ID,
							RECIPIENT_ID, BODY, TIME));
		}
	}

	public static class GroupTable implements BaseColumns {
		public static final String TableName = "GroupTb";
		public static final String GroupId = "_group_Id";
		public static final String GroupName = "_group_name";
		public static final String GroupAvatar = "_group_avatar";
		public static final String[] COLUMNS = { GroupId, GroupName,
				GroupAvatar };

		public static void setup(SQLiteDatabase db) {
			db.execSQL(String
					.format("CREATE TABLE IF NOT EXISTS %s "
							+ "(%s INTEGER PRIMARY KEY AUTOINCREMENT, %s INTEGER, %s TEXT NOT NULL, %s TEXT NOT NULL)",
							TableName, _ID, GroupId, GroupName, GroupAvatar));
		}
	}

	public static class RecentTable implements BaseColumns {
		public static final String TableName = "RecentTb";
		public static final String UserId = "_userId";
		public static final String GroupId = "_groupd_Id";
		public static final String[] COLUMNS = { UserId, GroupId };

		public static void setup(SQLiteDatabase db) {
			db.execSQL(String
					.format("CREATE TABLE IF NOT EXISTS %s "
							+ "(%s INTEGER PRIMARY KEY AUTOINCREMENT, %s INTEGER, %s INTEGER)",
							TableName, _ID, UserId, GroupId));
		}
	}
}
